package com.lemon.smartsafety.view.dialog.adapt;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lemon.smartsafety.R;



/**
 * 项目名称：teacher
 * 类描述：
 * 创建人：Administrator
 * 创建时间：2015/8/13 0013 下午 3:10
 * 修改人：Administrator
 * 修改时间：2015/8/13 0013 下午 3:10
 * 修改备注：
 */
public class SingleTextAdapt extends BaseAdapter {

    /**
     * TAG
     */
    private final String TAG = "SingleTextAdapt";

    /**
     * 选择项
     */
    private int m_nSelectItem = -1;

    /**
     * 数据列表
     */
    private String [] mList;


    /**
     * 布局泵
     */
    private LayoutInflater m_layInflater = null;

    private Context mContext;


    /**
     * 设置选择项
     *
     * @param n
     */
    public void setSelectItem(final int n) {
        m_nSelectItem = n;
    }

    /**
     * 设置数据列表
     */
    public void setList(String [] list) {
        this.mList = list;
    }

    /**
     * 构造函数
     *
     * @param context
     */
    public SingleTextAdapt(Context context, String [] list) {
        try {
            this.mContext = context;

            this.mList = list;

            // 布局泵
            m_layInflater = LayoutInflater.from(context);

        } catch (Exception e) {
        }
    }

    @Override
    public int getCount() {
        try {
            if (mList != null)
                return mList.length;
        } catch (Exception e) {
        }

        return 0;
    }

    @Override
    public Object getItem(int position) {
        try {
            if (mList != null)
                return mList[position];
        } catch (Exception e) {
        }

        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @SuppressWarnings({"deprecation"})
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        try {
            final ItemHolder holder;
            if (convertView != null) {
                // 支持器
                holder = (ItemHolder) convertView.getTag();
            } else {
                // 加载列表项
                convertView = m_layInflater.inflate(R.layout.item_dialog_single_txt,
                        null);

                // 支持器
                holder = new ItemHolder();

                holder.setTextView((TextView) convertView
                        .findViewById(R.id.textView));


                // 设置列表项
                convertView.setTag(holder);
            }

            //内容

            holder.getTextView().setText(mList[position]);




        } catch (Exception e) {
            e.printStackTrace();
        }

        return convertView;
    }

    /**
     * 项支持器类
     */
    private class ItemHolder {
        private TextView textView = null;


        public TextView getTextView() {
            return textView;
        }

        public void setTextView(TextView textView) {
            this.textView = textView;
        }
    }

    /**
     * 项支持器类
     */




}